Hello and welcome.
In this lecture we are going to implement some trackin to track or store this cause we get when the
brick is it.
So go and try and implement some scoring here so that each time the ball hits the brake and the break
disappear you get the mark or point for that.
So the track record that we are also going to implement win the game.
So when all the bricks have been hit and none is left on the compass that means you have won the game.
So we're going to how are we going to create an alert now come up when all the breaks have been hit.
To see Congress leisha's you have won the game.
So when I implement that in this election we are going to create a variable that we can use to record
this cause that you get.
So we begin by typing in the world far and we'll call the variable score to make it simple and give
it a value of zero to start with K and or saved that.
Next we are going to create a function that we can use to create the score so we can actually draw the
score is going to be a tax.
But the way you do.
You create a tax the same as where you create a ship.
So let's do that.
Okay I'm going to implement that just underneath me.
Draw bricks function just on the maths here we've create a function.
Okay.
You start with the word function
followed by the name of one accord a function.
I'll call it a draw
draw score.
Okay who made that look.
To save a bit of time.
I've completed the code here.
Let me just run through it with you.
So we begin with the word function to create a function.
The name of the function is drawn score and in between the curly braces.
There are some parameters so the way you create you create a text on mccumber so everything on a canvas
is treated more or less like graphics.
So you create a text the same way you would create a shape.
So you begin with the contents font method and you give it value.
The value here this 18 pixels is the size of the text on the font.
This this this this area here is the font family.
Most computers should have that font so you can always specify whatever font you want.
It is good to specify a font that most computers will have.
So that's the font here.
The context of field style is called or you would use to feel the call or you give the actual text that
will display the score.
So the context of field text method and artfully does the colouring of the text.
So in between these barren pieces here this core here is this call Eataly relates to the outroar score
that will be displayed for example if your points are 30.
This is way to be this plate plots.
What this plus is saying is that is telling you where it will pull xishun the score on the compass and
it has to appear those here.
So if say the position on the x axis on the y axis so it's pixels from the X and 20 pixels from the
y axis.
So that's the position.
It'll place the score on the canvas to implement the score so that each time a brick is hit you get
a point or score.
We need to amend or add a line of code to the quad lead coalition detection function so that each time
a brick is hit the function will increase the point so you get a point each time it brick is hit.
So we then implement that.
So let's look at the coalition detection function.
That's where we can implement that sule solution detection.
Right so this is the quick leash on detection function here.
This is where I will implement that right.
Just underneath here is where we're going to.
That's all we going to add.
The variable score reports we're going to type in score.
This blast blows means increment So every time the break is hit it'll increase.
That if you get the point added on to your score.
That's what this means.
So let's say that.
Next we need to insert.
And each state meant so that when all the breaks have been hit you get an alert message to tell you
you have won the game.
So we're going to implement in this state it will do that just on this score here on this score count.
That's where we'll implement school and begin with if.
All right.
I have completed the code just to save a bit of time.
So this is the state that implemented here.
So what I'm saying is that if the score is equal to Debree cruel count times the brick column count
is -- alert.
Congratulations you have won.
What that means is that if all the breaks have been cleared from the screen and not let you get this
message say congratulations you have won.
And what will commend the look is shown me is it that he reloads the game for his new session.
So I saved that are right.
The final thing we need to do is call how we call the draw.
Score function so good to wear on our function has been called from our love functions calls from the
draw function.
Okay so here.
This is where we're going to add medrol scores who added them all.
King
saw was a powder has been called.
Then the draws go from.
It's called before the leash detection.
So save that and then we can test it.
Okay let's test it and see.
So as you can see the aim is there.
So you got a score of two at the moment.
So let's see if we can add one more.
I missed that one.
Let's try one more
see Liz.
Let's call off two.
So that's how your.
This is where your call would be recorded.
Each time you hear the break this call comes here would be updated was all the breaks have been cleared
from the compass.
You get an alert saying you have won the game.
So that's it for this lecture.
So we have implemented a scoring for the game and som quickly shown detection with the in our previous
lecture.
So the game is almost complete.
While we're on what we need to do next is implement some mouse control at the moment.
I can't use my mouse to move the paddle so I have to be using the keyboard keys on the keyboard the
errors back arrows to be moving the pad also is a bit cumbersome.
Some will implement some mouse control in the next lecture.
That way I can use the mouse movement will respond to the paddle so as more my mounds of paths will
move with me.
With the mouse movement so make it a lot easier to control the ball the ball with the paddle.
So see you in the next lecture.
Thank you both hon.